package com.foreknow.demo12;

import com.foreknow.demo2.Admin;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        //1. 创建一个List集合
        List<Map<String,Admin>> list = new ArrayList<>();
        //2. 创建三个Map对象
        Map<String,Admin> map1 = new HashMap<>();
        Admin admin1 = new Admin();
        admin1.setName("tom");
        Admin admin2 = new Admin();
        admin2.setName("fender");
        map1.put("1",admin1);
        map1.put("2",admin2);

        Map<String,Admin> map2 = new HashMap<>();
        Admin admin3 = new Admin();
        admin3.setName("tom3");
        Admin admin4 = new Admin();
        admin4.setName("fender4");
        map2.put("3",admin3);
        map2.put("4",admin4);

        Map<String,Admin> map3 = new HashMap<>();
        Admin admin5 = new Admin();
        admin5.setName("tom5");
        Admin admin6 = new Admin();
        admin6.setName("fender6");
        map3.put("5",admin5);
        map3.put("6",admin6);
        //3. 将三个map对象保存到list集合中
        list.add(map1);
        list.add(map2);
        list.add(map3);

        //4. 遍历输出每个对象的信息
        for(int i = 0;i<list.size();i++) {
            Map<String,Admin> map = list.get(i);
            //遍历Map集合
            Set<Map.Entry<String,Admin>> set = map.entrySet();
            Iterator<Map.Entry<String,Admin>> it = set.iterator();
            while (it.hasNext()) {
                Map.Entry<String,Admin> entry = it.next();
                String key = entry.getKey();
                Admin admin = entry.getValue();
                System.out.println(key+"----"+admin.getName());
            }
        }
    }
}
